//
//  DYZSongListHeaderView.m
//  wind
//
//  Created by dllo on 16/1/12.
//  Copyright © 2016年 李金明. All rights reserved.
//

#import "DYZSongListHeaderView.h"
#import "Masonry.h"

@interface DYZSongListHeaderView ()

@property (nonatomic, retain) UILabel *countL;
@property (nonatomic, retain) UIButton *createBtn;
@property (nonatomic, retain) UIButton *manageBtn;
@property (nonatomic, retain) UILabel *title;

@end

@implementation DYZSongListHeaderView

- (void)dealloc
{
    [_title release];
    [_countL release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createViews];
    }
    return self;
}

- (void)createViews
{
//    self.backgroundColor = [UIColor blackColor];
    
    self.title = [[UILabel alloc] init];
    self.title.text = @"我创建的歌单";
    self.title.font = [UIFont boldSystemFontOfSize:18];
    [self addSubview:self.title];
    [_title release];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self);
        make.left.mas_equalTo(@12);
        make.width.mas_equalTo(@120);
        make.top.mas_equalTo(@10);
        make.bottom.mas_equalTo(@-10);
        
    }];
    
    self.countL = [[UILabel alloc] init];
    self.countL.backgroundColor = [UIColor blueColor];
    [self addSubview:self.countL];
    [_countL release];
    
    self.createBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.createBtn addTarget:self action:@selector(createAction)forControlEvents:UIControlEventTouchUpInside];
    [self.createBtn setTitle:@"新建" forState:UIControlStateNormal];
    [self.createBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.createBtn setImage:[UIImage imageNamed:@"iconfont-xinjian"] forState:UIControlStateNormal];
    self.createBtn.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    self.createBtn.layer.borderWidth = 2.0;
    [self addSubview:self.createBtn];
    
    self.manageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.manageBtn addTarget:self action:@selector(manageAction)forControlEvents:UIControlEventTouchUpInside];
    [self.manageBtn setTitle:@"管理" forState:UIControlStateNormal];
    [self.manageBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.manageBtn setImage:[UIImage imageNamed:@"iconfont-guanlixitong"] forState:UIControlStateNormal];
    self.manageBtn.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    self.manageBtn.layer.borderWidth = 2.0;
    [self addSubview:self.manageBtn];
    
    [self.createBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self);
        make.left.equalTo(self.countL.mas_right).with.offset(30);
        make.right.equalTo(self.manageBtn.mas_left).with.offset(-10);
        make.top.mas_equalTo(@10);
        make.bottom.mas_equalTo(@-10);
        
    }];
    
    [self.manageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self);
        make.left.equalTo(self.createBtn.mas_right).with.offset(10);
        make.right.mas_equalTo(@-10);
        make.height.mas_equalTo(self.createBtn);
        make.width.mas_equalTo(self.createBtn);
        
    }];

    
}

// 管理按钮
- (void)manageAction
{
    NSLog(@"管理");
}

// 新建按钮
- (void)createAction
{
    NSLog(@"新建");
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.countL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self);
        make.left.equalTo(self.title.mas_right).with.offset(10);
        make.width.mas_equalTo(@60);
        make.top.mas_equalTo(@10);
        make.bottom.mas_equalTo(@-10);
        
    }];
    
}

@end
